#1628: Support for OS specific CVEs - #2370
Conversation
Coverage Report for CI Build 33722231185Coverage increased (+0.07%) to 73.682%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions39 previously-covered lines in 3 files lost coverage.
Coverage Stats💛 - Coveralls |
c5309e2 to
e394226
Compare
Ali-Shariati-Najafabadi
left a comment
There was a problem hiding this comment.
Pulled the branch and ran the full test suite locally plus checkstyle. Build is green and the core idea (isAffected/merge/JSON round-trip) works and is tested. Found one actual crash bug and a few smaller things worth looking at before merging, left inline.
1fbec9a to
832df30
Compare
hohwille
left a comment
There was a problem hiding this comment.
@laert-ll thanks for your PR. Great work, well done 👍
I actually had to read my own story again to do the review properly.
Only then I remembered why we had to do this so complicated instead of just having an os property with an array of OSes that the CVE applies to. But in reality a CVE can apply versions for all OS but other versions only for particular OS. With this more complex design we can represent all the states we need to express the reality that actually is complex.
I left some review comments which are all small constructive suggestions to make the code cleaner or nicer but nothing I found was wrong in any way.
IMHO we can apply all suggestions and then merge this PR.
Great that you already fixed the merge method so completing the story to also use this new feature in the security updater process is now very easy.
p.s.: You could have passed the SystemInfo instead of just OperatingSystem since then we do not have to refactor anything in the future if we might also need to support CVE versions that are even specific to the combination of OS + architecture. But since this is not needed for now, we can leave that as is and refactor only in case we ever run into such demand.
| if (this.conditions.isEmpty() && other.isEmpty()) { | ||
| return Map.of(); | ||
| } |
There was a problem hiding this comment.
Wouldn't this make more sense here?
| if (this.conditions.isEmpty() && other.isEmpty()) { | |
| return Map.of(); | |
| } | |
| if (this.conditions.isEmpty()) { | |
| return other; | |
| } |
| List<VersionRange> newRanges = newConditions.computeIfAbsent(os, key -> new ArrayList<>()); | ||
| ranges.forEach(range -> mergeVersionRage(newRanges, range)); | ||
| }); | ||
| return newConditions; |
There was a problem hiding this comment.
This Cve is a record and should stay immutable:
| return newConditions; | |
| return Map.copyOf(newConditions); |
| Map<String, List<VersionRange>> newConditions = new TreeMap<>(); | ||
| this.conditions.forEach((os, ranges) -> newConditions.put(os, new ArrayList<>(ranges))); |
There was a problem hiding this comment.
Can be simplified and made more efficient:
| Map<String, List<VersionRange>> newConditions = new TreeMap<>(); | |
| this.conditions.forEach((os, ranges) -> newConditions.put(os, new ArrayList<>(ranges))); | |
| Map<String, List<VersionRange>> newConditions = new TreeMap<>(this.conditions); |
This PR fixes #1628
Implemented changes:
security.jsonCVE model extended so that a single CVE can express affected version ranges that only apply on specific operating systems.conditionsmap to theCvemodel.CveJsonDeserializer/CveJsonSerializerread and writeconditions. It is only written when present, so existingsecurity.jsonfiles remain unchanged.Cve.isAffected(version, os)combines the globalversionswith the current OS's conditional ranges;Cve.merge(...)also merges the per-OS conditions.Testing instructions
Run
mvn clean testManual (single machine):
<IDE_ROOT>/urls/<tool>/<edition>/security.json(create if absent) and add a CVE whose globalversionsdo NOT match the version you'll install, but whoseconditionsfor your current OS (windows/linux/mac) do:{ "issues": [ { "id": "CVE-TEST-OS", "severity": 9.0, "versions": ["(0,0.0.1)"], "conditions": { "linux": ["[<version>]"] } } ] }Checklist for this PR
Make sure everything is checked before merging this PR. For further info please also see
our DoD.
mvn clean testlocally all tests pass and build is successful#«issue-id»: «brief summary»(e.g.#921: fixed setup.batand notfeature/921 fixed setup.bat). If no issue ID exists, title only.In Progressand assigned to you or there is no issue (might happen for very small PRs)with
internalpom.xmlfiles or otherwise if runtime dependencies changed, you have updated our LICENSE.asciidoc